package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.sysadmin.zsj.domain.ProjectRecommend;
import com.hjxr.sysadmin.zsj.service.IProjectRecommendService;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;

/**
 * 推介项目详情Controller
 *
 * @author zc
 * @date 2021-03-25
 */
@Api("拜访信息管理")
@RestController
@RequestMapping("/recommend")
public class ProjectRecommendController extends BaseController
{
    @Autowired
    private IProjectRecommendService projectRecommendService;

    /**
     * 查询推介项目详情列表
     */
    @ApiOperation("查询推介项目详情列表")
    //@PreAuthorize("@ss.hasPermi('system:recommend:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectRecommend projectRecommend)
    {
        startPage();
        List<ProjectRecommend> list = projectRecommendService.selectProjectRecommendList(projectRecommend);
        return getDataTable(list);
    }

    /**
     * 导出推介项目详情列表
     */
    @ApiOperation("导出推介项目详情列表")
    //@PreAuthorize("@ss.hasPermi('system:recommend:export')")
    @Log(title = "导出推介项目详情列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectRecommend projectRecommend)
    {
        List<ProjectRecommend> list = projectRecommendService.selectProjectRecommendList(projectRecommend);
        ExcelUtil<ProjectRecommend> util = new ExcelUtil<ProjectRecommend>(ProjectRecommend.class);
        return util.exportExcel(list, "recommend");
    }

    /**
     * 获取推介项目详情详细信息
     */
    @ApiOperation("获取推介项目详情详细信息")
    //@PreAuthorize("@ss.hasPermi('system:recommend:query')")
    @GetMapping(value = "/{proId}")
    public AjaxResult getInfo(@PathVariable("proId") Long proId)
    {
        return AjaxResult.success(projectRecommendService.selectProjectRecommendById(proId));
    }

    /**
     * 新增推介项目详情
     */
    @ApiOperation("新增推介项目详情")
    //@PreAuthorize("@ss.hasPermi('system:recommend:add')")
    @Log(title = "新增推介项目详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectRecommend projectRecommend)
    {
        return toAjax(projectRecommendService.insertProjectRecommend(projectRecommend));
    }

    /**
     * 修改推介项目详情
     */
    @ApiOperation("修改推介项目详情")
    //@PreAuthorize("@ss.hasPermi('system:recommend:edit')")
    @Log(title = "修改推介项目详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectRecommend projectRecommend)
    {
        return toAjax(projectRecommendService.updateProjectRecommend(projectRecommend));
    }

    /**
     * 删除推介项目详情
     */
    @ApiOperation("删除推介项目详情")
    //@PreAuthorize("@ss.hasPermi('system:recommend:remove')")
    @Log(title = "删除推介项目详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{proIds}")
    public AjaxResult remove(@PathVariable Long[] proIds)
    {
        return toAjax(projectRecommendService.deleteProjectRecommendByIds(proIds));
    }
}
